<template>
  <div class="cart-list">
        <div class="imgbutt">
            <div @click="click_cart">
            <img src="@/assets/img/cart/gx.png" alt=""  :class="{a:!item.checked}">
             <img src="@/assets/img/cart/wgx.png" alt="" :class="{a:item.checked}">
             </div>
        </div>
        <div class="item-img">
          <img :src="item.imge" alt="商品图片" />
        </div>
        <div class="item-info">
          <div class="item-title">{{ item.title }}</div>
          <div class="item-desc">商品描述: {{ item.desc }}</div>
          <div class="info-bottom">
            <div class="item-price left">¥{{ item.price }}</div>
            <div class="item-count right">x{{ item.count }}</div>
          </div>
        </div>

  </div>
</template>

<script>
export default {
    name:"CartlistItem",
    props:{
        item:{
            type:Object,
            default(){
                return {}
            }

        }
    },
    data() {
        return {
            isTrue:true
        }
    },
    methods:{
        click_cart(){
            let count=0
            this.item.checked=!this.item.checked
            for(let i = 0;i<this.$store.state.cartList.length;i++){
                if(this.$store.state.cartList[i].checked==true){
                    count++
                }
            }
            if(count==this.$store.state.cartList.length){
                this.$emit('all_select',true)
            } else{
                this.$emit("all_select",false)

            }
        }
    }
}
</script>

<style scoped>
.imgbutt{
    width: 7%;
    line-height: 110px;
    margin-left: 5px;
}
.a{
    display: none;
    
}
.cart-list {
    display: flex;
    border-bottom: 1px solid #999;

}

.shop-item {
  font-size: 0;
  display: flex;
  width: 100%;
  padding: 5px;
  border-bottom: 1px solid #cccccc;
}
.shop-item:last-child {
  border-bottom: 0;
}
.item-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 12%;
}
.item-title,
.item-desc {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.item-img {
  padding: 5px;
}
.item-img img {
  display: block;
  width: 80px;
  height: 100px;
  border-radius: 5px;
  object-fit: cover;
}
.item-info {
  font-size: 17px;
  position: relative;
  overflow: hidden;
  width: 88%;
  padding: 5px 10px;
  color: #333333;
}
.item-info .item-desc {
  font-size: 14px;
  margin-top: 15px;
  color: #666666;
}
.info-bottom {
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  margin-top: 10px;
}
.info-bottom .item-price {
  color: #ff4500;
}
</style>